package com.learn.callback.level3;

import com.learn.callback.level2.Callback;
import lombok.extern.slf4j.Slf4j;

/**
 * <p>项目名称: design-pattern </p>
 *
 * <p>文件名称: Task </p>
 *
 * Template-method class for callback hook execution
 */
@Slf4j
public abstract class Task {

    public final void executeWith(Callback callback){

        log.info("Task 开始 executeWith方法");
        execute();
        log.info("Task 完成 executeWith方法");

        log.info("Task 开始 回调 Callback 的call方法");
        if (callback != null){
            callback.call();
        }
        log.info("Task 完成 回调 Callback 的call方法");

    }

    public abstract void execute();
}
